package org.sardine.beans.support;

import java.lang.reflect.Constructor;

import org.sardine.beans.BeanUtils;
import org.sardine.util.ClassUtils;

public class BeanObjectInstantiation{
	
	public Object createObject(String className){
		
		Class objClass = null;
		
		try {
			
			objClass = ClassUtils.forName(className);
			if(objClass.isInterface()){
				throw new BeanObjectInstantiationException("不能实例化接口类型："+objClass);
			}
			
		} catch (ClassNotFoundException e) {
			throw new BeanObjectInstantiationException("找不到此类："+objClass,e);
		}
		
		return createObject(objClass);
		
	}
	
	public Object createObject(Class objClass){
		
		if(objClass.isInterface()){
			throw new BeanObjectInstantiationException("不能实例化接口类型："+objClass);
		}
		return BeanUtils.instantiateClass(objClass);
		
	}

}
